package com.example.juegot;


import java.util.ArrayList;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay.OnItemGestureListener;
import org.osmdroid.views.overlay.OverlayItem;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class MainActivity extends Activity {

	private MapView myOpenMapView;
	private MapController myMapController;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		try{
		setContentView(R.layout.activity_main);
		myOpenMapView =(MapView)findViewById(R.id.openmapview);
		myOpenMapView.setBuiltInZoomControls(true);
		myMapController = myOpenMapView.getController();
		myMapController.setZoom(256);
		myMapController.setCenter(new GeoPoint(6.0282012, -75.4302517));
		ArrayList<OverlayItem> anotherOverlayItemArray;
		anotherOverlayItemArray = new ArrayList<OverlayItem>();
		anotherOverlayItemArray.add(new OverlayItem("0, 0", "0, 0", new GeoPoint(0, 0)));
		anotherOverlayItemArray.add(new OverlayItem("La ceja", "La ceja", new GeoPoint(6.0282012, -75.4302517)));		
		OnItemGestureListener<OverlayItem> myOnItemGestureListener = new OnItemGestureListener<OverlayItem>() {
			@Override
			public boolean onItemLongPress(int arg0, OverlayItem arg1) {
				// TODO Auto-generated method stub
				return false;
			}
			@Override
			public boolean onItemSingleTapUp(int index, OverlayItem item) {			
				Toast.makeText(
			            MainActivity.this,
			            item.mDescription + "\n" + item.mTitle + "\n"
			                + item.mGeoPoint.getLatitudeE6() + " : "
			                + item.mGeoPoint.getLongitudeE6(),
			            Toast.LENGTH_LONG).show();
			             
			        return true;
			}
		};
		capa anotherItemizedIconOverlay = new capa(this, anotherOverlayItemArray, myOnItemGestureListener);
		myOpenMapView.getOverlays().add(anotherItemizedIconOverlay);
		anotherItemizedIconOverlay.setFocusItemsOnTap(true);
		anotherItemizedIconOverlay.setFocusedItem(1);
		ArrayList<GeoPoint> puntosLinea = new ArrayList<GeoPoint>();
		puntosLinea.add(new GeoPoint(6.0282012, -75.4302517));
		puntosLinea.add(new GeoPoint(7.0282012, -60.4302517));
		myOpenMapView.getOverlays().add(anotherItemizedIconOverlay.dibujarLinea(puntosLinea));
		}finally{
			
		}
	}
}